//#define USE_OR_MASKS

#include <p18f46k22.h>
#include <usart.h>

#pragma config FOSC = HSHP //HS oscillator (high power > 16 MHz)
#pragma config WDTEN = OFF, LVP = OFF, MCLRE = EXTMCLR  //Watchdog timer off, single-supply ICSP disabled, MCLR pin enabled

#pragma code

void init_gps_l70(void);


void InterruptHandlerHigh (void);


#pragma code _vecteur_it_high = 0x08
void itHigh(void)
{
    _asm 
        goto InterruptHandlerHigh
    _endasm
}

#pragma interrupt InterruptHandlerHigh

void InterruptHandlerHigh (void)
{       
	unsigned char tamp;
    if(PIR1bits.RC1IF)
    {
		LATBbits.LATB3 = 1;
		tamp = getc1USART();		
		LATBbits.LATB3 = 0;
    }

}



void main(void)
{
        PORTC = 0x00;
        ANSELC = 0x00;

		//Enable interrupts
        INTCONbits.GIEH = 1;            //Enable all high priority interrupt
        INTCONbits.GIEL = 1;            //Enable all low priority interrupt
		
        ANSELBbits.ANSB3 = 0;           
        TRISBbits.RB3 = 0;              

        init_gps_l70();

        while(1);      
}

void init_gps_l70()
{
        unsigned char SET_NMEA_OUTPUT[] = "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28\r\n";//set GGA output
        Open1USART(USART_TX_INT_OFF & USART_RX_INT_ON  & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_LOW, 31);
		puts1USART((char *)SET_NMEA_OUTPUT);
}
